/*====================================================================================
    EVS Codec 3GPP TS26.442 Sep 15, 2014. Version 12.0.0
  ====================================================================================*/

#ifndef __VAD_CONST_H__
#define __VAD_CONST_H__


#define FIX_32(A) (Word32)(((A) >= 0) ? ((Word32)((A)*(INT_MAX)+0.5)) : ((Word32)((A)*(INT_MAX)-0.5)))
#define FIX_16(A) (Word16)(((A) >= 0) ? ((Word16)((A)*(SHRT_MAX)+0.5)) : ((Word16)((A)*(SHRT_MAX)-0.5)))

#define CONST_32_Q31(A)	    (Word32)(((A) >= 0) ? ((Word32)((A)*(2147483647 )+0.5)) : ((Word32)((A)*(2147483647 )-0.5)))
#define CONST_32_Q16(A)	(Word32)(((A) >= 0) ? ((Word32)((A)*(65535 )+0.5)) : ((Word32)((A)*(65535)-0.5)))
#define CONST_32_Q25(A)	(Word32)(((A) >= 0) ? ((Word32)((A)*(33554431 )+0.5)) : ((Word32)((A)*(33554431)-0.5)))
#define CONST_32_Q10(A)	(Word32)(((A) >= 0) ? ((Word32)((A)*(1023 )+0.5)) : ((Word32)((A)*(1023)-0.5)))

#define CONST_16_Q21(A)	(Word16)(((A) >= 0) ? ((Word16)((A)*(2097151 )+0.5)) : ((Word16)((A)*(2097151)-0.5)))
#define CONST_16_Q20(A)	(Word16)(((A) >= 0) ? ((Word16)((A)*(1048575 )+0.5)) : ((Word16)((A)*(1048575)-0.5)))
#define CONST_16_Q19(A)	(Word16)(((A) >= 0) ? ((Word16)((A)*(524287 )+0.5)) : ((Word16)((A)*(524287)-0.5)))
#define CONST_16_Q24(A)	(Word16)(((A) >= 0) ? ((Word16)((A)*(16777215 )+0.5)) : ((Word16)((A)*(16777215)-0.5)))
#define CONST_16_Q23(A)	(Word16)(((A) >= 0) ? ((Word16)((A)*(8388607 )+0.5)) : ((Word16)((A)*(8388607)-0.5)))
#define CONST_16_Q15(A) (Word16)(((A) >= 0) ? ((Word16)((A)*(32767)+0.5)) : ((Word16)((A)*(32767)-0.5)))
#define CONST_16_Q14(A) (Word16)(((A) >= 0) ? ((Word16)((A)*(16383)+0.5)) : ((Word16)((A)*(16383)-0.5)))
#define CONST_16_Q13(A) (Word16)(((A) >= 0) ? ((Word16)((A)*(8191)+0.5)) : ((Word16)((A)*(8191)-0.5)))
#define CONST_16_Q12(A) (Word16)(((A) >= 0) ? ((Word16)((A)*(4095)+0.5)) : ((Word16)((A)*(4095)-0.5)))
#define CONST_16_Q10(A) (Word16)(((A) >= 0) ? ((Word16)((A)*(1023)+0.5)) : ((Word16)((A)*(1023)-0.5)))

#define MUL_F(A,B)       Mpy_32_16_1((A),(B))
#endif

